<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../include/taglib.jsp" %>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
    <div class="modal-dialog modal-lg">
        <div class="modal-content" id="editPage">
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <div class="form-panel">
            <h4 class="mb"><a href="javascript:jumpMenu('${ctx}/index/usual')"> 运营平台 </a><i class="fa fa-angle-right"></i>
                <a href="javascript:jumpMenu('${ctx}/sysuser/page')"> 系统用户管理 </a>
            </h4>
            <form class="form-inline" role="form" id="sourceForm" method="post">
                <div class="form-group">
                    <label class="sr-only"></label>
                    <input type="text" class="form-control" name="keyWords"
                           placeholder="输入关键字">
                </div>
                <div class="pull-right">
                    <button type="button" class="btn btn-theme04"
                            onclick="document.getElementById('sourceForm').reset();$('#searchSubmit').click();">清除
                    </button>
                    <button type="button" class="btn btn-theme" id="searchSubmit"
                            onclick="queryList('${ctx}/sysuser/list', 'sourceForm', '_list')">搜 索
                    </button>
                    <button type="button" class="btn btn-theme03" data-toggle="modal"
                            data-target="#myModal" onclick="edit();">
                        <i class="fa fa-user-plus fa-1x"></i>
                        新增
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<%--<div class="row mt">
    <div class="col-md-12">
        <div class="form-panel">
        </div>
    </div>
</div>--%>

<div class="row list">
    <div class="col-md-12">
        <div class="content-panel" id="_list">
        </div><!-- /content-panel -->
    </div><!-- /col-md-12 -->
</div>

<script type="text/javascript">
    $(function () {
        $("#searchSubmit").click();
        $("#sourceForm input").keydown(function (e) {
            if (e.which == 13) {//.which属性判断按下的是哪个键，回车键的键位序号为13
                $("#searchSubmit").click();//触发搜索按钮的点击事件
                return false;
            }
        });
    });

    function edit(id) {
        var package = new AJAXPacket("${ctx}/sysuser/edit");
        package.data.add("id", id);
        core.ajax.dynamicLoadpage(package, "editPage");
        package = null;
    }

    function resetPwd(id) {
        var reset = function () {
            var package = new AJAXPacket("${ctx}/sysuser/resetPwd");
            package.data.add("id", id);
            core.ajax.sendPacket(package, function (response) {
                if (response.data.success) {
                    alertMsg.sure("密码已重置:"+response.data.resultMap.newPwd);
                    jumpPageTo("_list");
                } else {
                    alertMsg.error(response.data.errMsg);
                }
            });
            package = null;
        }
        alertMsg.confirm('确定将此用户密码恢复默认值吗？', reset);
    }

    function del(id) {
        var del = function () {
            var package = new AJAXPacket("${ctx}/sysuser/delete");
            package.data.add("id", id);
            core.ajax.sendPacket(package, function (response) {
                if (response.data.success) {
                    alertMsg.correct("成功！");
                    jumpPageTo("_list");
                } else {
                    alertMsg.error(response.data.errMsg);
                }
            });
            package = null;
        }
        alertMsg.confirm('确定执行此删除操作吗？', del);
    }

</script>